package ORM;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.connetion.ConnectionLink;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

public class ItemGoods {
	private String item;
	private int i_points, number, i_no;
	private Connection conn;
	private PreparedStatement ps;
	private ResultSet rs;
	private ArrayList<ItemGoods> list =new ArrayList<>();
	
	public ItemGoods()
	{
		
	}
	public ItemGoods(String item, int i_points, int number, int i_no)
	{
		this.item = item;
		this.i_points = i_points;
		this.number = number;
		this.i_no = i_no;
	}
	public ArrayList<ItemGoods> selectItem()
	{
		conn = ConnectionLink.getMysqlConn();
		try {
			ps = (PreparedStatement) conn.prepareStatement("Select * from item ");
			rs = ps.executeQuery();

			   while(rs.next())
	           {
				   ItemGoods ti = new ItemGoods(rs.getString(1),rs.getInt(2),rs.getInt(3), rs.getInt(4));
	               list.add(ti);
	           }
	         
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		  return list;
	}
	public String getItem() {
		return item;
	}
	public int getI_points() {
		return i_points;
	}
	public int getNumber() {
		return number;
	}
	public int getI_no() {
		return i_no;
	}
	public Connection getConn() {
		return conn;
	}
	public PreparedStatement getPs() {
		return ps;
	}
	public ResultSet getRs() {
		return rs;
	}
	public ArrayList<ItemGoods> getList() {
		return list;
	}
	
}
